<!DOCTYPE html>
<html lang="zh-cn">
<head prefix="og: http://ogp.me/ns#">
  <meta charset="utf-8">
  <title>axios中文文档|axios中文网 | axios</title>
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- Canonical links -->
  <link rel="canonical" href="http://axios-js.com/zh-cn/docs/index.html">
  <!-- Alternative links -->
  
    
      <link rel="alternative" hreflang="en" href="http://axios-js.com/docs/index.html">
    
      <link rel="alternative" hreflang="zh-cn" href="http://axios-js.com/zh-cn/docs/index.html">
    
  
  <!-- Icon -->
  <link rel="apple-touch-icon" sizes="57x57" href="http://www.axios-js.com/icon/apple-touch-icon-57x57.png">
  <link rel="apple-touch-icon" sizes="114x114" href="http://www.axios-js.com/icon/apple-touch-icon-114x114.png">
  <link rel="apple-touch-icon" sizes="72x72" href="http://www.axios-js.com/icon/apple-touch-icon-72x72.png">
  <link rel="apple-touch-icon" sizes="144x144" href="http://www.axios-js.com/icon/apple-touch-icon-144x144.png">
  <link rel="apple-touch-icon" sizes="60x60" href="http://www.axios-js.com/icon/apple-touch-icon-60x60.png">
  <link rel="apple-touch-icon" sizes="120x120" href="http://www.axios-js.com/icon/apple-touch-icon-120x120.png">
  <link rel="apple-touch-icon" sizes="76x76" href="http://www.axios-js.com/icon/apple-touch-icon-76x76.png">
  <link rel="apple-touch-icon" sizes="152x152" href="http://www.axios-js.com/icon/apple-touch-icon-152x152.png">
  <link rel="icon" type="image/png" href="http://www.axios-js.com/icon/favicon-196x196.png" sizes="196x196">
  <link rel="icon" type="image/png" href="http://www.axios-js.com/icon/favicon-160x160.png" sizes="160x160">
  <link rel="icon" type="image/png" href="http://www.axios-js.com/icon/favicon-96x96.png" sizes="96x96">
  <link rel="icon" type="image/png" href="http://www.axios-js.com/icon/favicon-16x16.png" sizes="16x16">
  <link rel="icon" type="image/png" href="http://www.axios-js.com/icon/favicon-32x32.png" sizes="32x32">
  <meta name="msapplication-TileColor" content="#2f83cd">
  <meta name="msapplication-TileImage" content="/icon/mstile-144x144.png">
  <meta name="generator" content="Hexo 4.1.0">
  <!-- CSS -->
  <!-- build:css build/css/navy.css -->
  
<link rel="stylesheet" href="static/css/navy.css">

  <!-- endbuild -->
  <link href="static/css/css.css" rel="stylesheet" type="text/css">
  <link rel="stylesheet" href="static/css/font-awesome.min.css">
  <link rel="stylesheet" href="static/css/docsearch.min.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css">
  <!-- RSS -->
  <link rel="alternate" href="http://www.axios-js.com/atom.xml" title="axios">
  <!-- Open Graph -->
  <meta name="description" content="欢迎使用 axios，本文档将帮助您快速上手。(troubleshooting.html) 中的解答， 什么是 axios？Axios 是一个基于 promise 的 HTTP 库，可以用在浏览器和 node.js 中。 axios Axios 是一个基于 promise 的 HTTP 库，可以用在浏览器和 node.js 中。  特性 从浏览器中创建 XMLHttpRequests 从 node">
<meta property="og:type" content="website">
<meta property="og:title" content="axios中文文档|axios中文网">
<meta property="og:url" content="http://axios-js.com/zh-cn/docs/index.html">
<meta property="og:site_name" content="axios">
<meta property="og:description" content="欢迎使用 axios，本文档将帮助您快速上手。(troubleshooting.html) 中的解答， 什么是 axios？Axios 是一个基于 promise 的 HTTP 库，可以用在浏览器和 node.js 中。 axios Axios 是一个基于 promise 的 HTTP 库，可以用在浏览器和 node.js 中。  特性 从浏览器中创建 XMLHttpRequests 从 node">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://img.shields.io/npm/v/axios.svg?style=flat-square">
<meta property="og:image" content="https://img.shields.io/travis/axios/axios.svg?style=flat-square">
<meta property="og:image" content="https://img.shields.io/coveralls/mzabriskie/axios.svg?style=flat-square">
<meta property="og:image" content="https://img.shields.io/npm/dm/axios.svg?style=flat-square">
<meta property="og:image" content="https://img.shields.io/gitter/room/mzabriskie/axios.svg?style=flat-square">
<meta property="og:image" content="https://www.codetriage.com/axios/axios/badges/users.svg">
<meta property="og:image" content="https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png">
<meta property="og:image" content="https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png">
<meta property="og:image" content="https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png">
<meta property="og:image" content="https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png">
<meta property="og:image" content="https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png">
<meta property="og:image" content="https://raw.github.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png">
<meta property="og:image" content="https://saucelabs.com/open_sauce/build_matrix/axios.svg">
<meta property="og:image" content="http://axios-js.com/icon/les01.jpeg">
<meta property="og:image" content="http://axios-js.com/icon/les02.jpeg">
<meta property="og:image" content="http://axios-js.com/icon/les03.jpeg">
<meta property="og:image" content="http://axios-js.com/icon/les04.jpeg">
<meta property="article:published_time" content="2021-10-28T14:07:53.000Z">
<meta property="article:modified_time" content="2021-10-28T14:07:53.000Z">
<meta property="article:author" content="Hexo">
<meta property="article:tag" content="axios中文文档">
<meta property="article:tag" content=" axios API中文">
<meta property="article:tag" content=" axios 跨域请求">
<meta property="article:tag" content=" axios post">
<meta property="article:tag" content=" axios get">
<meta property="article:tag" content=" axios 配置">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://img.shields.io/npm/v/axios.svg?style=flat-square">
  <!-- Analytics -->
  
<script>
    (function(h,o,t,j,a,r){
        h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
        h._hjSettings={hjid:1120304,hjsv:6};
        a=o.getElementsByTagName('head')[0];
        r=o.createElement('script');r.async=1;
        r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
        a.appendChild(r);
    })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');
</script>

<a title="Real Time Web Analytics" href="javascript:;" target="_blank" rel="noopener"><img src="static/picture/badge.gif" border="0"></a>
<script>var clicky_site_ids = clicky_site_ids || []; clicky_site_ids.push(101192693);</script>
<script async="" src="static/js/js.js"></script>



</head>

<body>
  <div id="container">
    <header id="header" class="wrapper">
  <div id="header-inner" class="inner">
    <h1 id="logo-wrap">
      <a href="index.html" id="logo">axios</a>
    </h1>
    <nav id="main-nav">
      <a href="" class="main-nav-link">文档</a><a href="index2.html" class="main-nav-link">博客</a>
      <a href="javascript:;" target="_blank" rel="noopener" class="main-nav-link"><i class="fa fa-github-alt"></i></a>
      <div id="search-input-wrap">
        <div id="search-input-icon">
          <i class="fa fa-search"></i>
        </div>
        <input type="search" id="search-input" placeholder="Search...">
      </div>
    </nav>
    <div id="lang-select-wrap">
      <label id="lang-select-label"><i class="fa fa-globe"></i><span>简体中文</span></label>
      <select id="lang-select" data-canonical="docs/index.html">
        
          <option value="en">undefined</option>
        
          <option value="zh-cn" selected="">简体中文</option>
        
      </select>
    </div>
    <a id="mobile-nav-toggle">
      <span class="mobile-nav-toggle-bar"></span>
      <span class="mobile-nav-toggle-bar"></span>
      <span class="mobile-nav-toggle-bar"></span>
    </a>
  </div>
</header>

    <div id="content-wrap">
  <div id="content" class="wrapper">
    <div id="content-inner">
      <article class="article-container" itemscope="" itemtype="http://schema.org/Article">
        <div class="article-inner">
          <div class="article">
            <div class="inner">
              <header class="article-header">
                <h1 class="article-title" itemprop="name">axios中文文档|axios中文网</h1>
                <a href="javascript:;" target="_blank" rel="noopener" class="article-edit-link" title="改进本文"></a>
              </header>
              <div class="article-content" itemprop="articleBody">
                <p class="vultr-desc">
                  本站由axios爱好者共建，部署在vultr vps上，推荐使用vultr!价格实惠，实力雄厚。
                  最近新注册用户充值$25,可额外获赠$50,搭建博客必备。
                  <a href="javascript:;" target="_blank" rel="noopener">前往注册</a>
                </p>

                <div id="lagou-vip">
                  <a href="javascript:;" target="_blank" rel="noopener">京东双11，现在不买等一年！犒劳自己--></a>
                </div>
                <p>欢迎使用 axios，本文档将帮助您快速上手。(troubleshooting.html) 中的解答，</p>
<h2 id="什么是-axios？" class="article-heading"><a href="#什么是-axios？" class="headerlink" title="什么是 axios？"></a>什么是 axios？<a class="article-anchor" href="#什么是-axios？" aria-hidden="true"></a></h2><p>Axios 是一个基于 promise 的 HTTP 库，可以用在浏览器和 node.js 中。</p>
<h1 id="axios" class="article-heading"><a href="#axios" class="headerlink" title="axios"></a>axios<a class="article-anchor" href="#axios" aria-hidden="true"></a></h1><p><a href="javascript:;" target="_blank" rel="noopener"><img src="static/picture/axios1.svg" alt="npm version"></a><br><a href="javascript:;" target="_blank" rel="noopener"><img src="static/picture/axios2.svg" alt="build status"></a><br><a href="javascript:;" target="_blank" rel="noopener"><img src="static/picture/axios3.svg" alt="code coverage"></a><br><a href="javascript:;" target="_blank" rel="noopener"><img src="static/picture/axios4.svg" alt="npm downloads"></a><br><a href="javascript:;" target="_blank" rel="noopener"><img src="static/picture/axios5.svg" alt="gitter chat"></a><br><a href="javascript:;" target="_blank" rel="noopener"><img src="static/picture/users.svg" alt="code helpers"></a></p>
<p>Axios 是一个基于 promise 的 HTTP 库，可以用在浏览器和 node.js 中。 </p>
<h2 id="特性" class="article-heading"><a href="#特性" class="headerlink" title="特性"></a>特性<a class="article-anchor" href="#特性" aria-hidden="true"></a></h2><ul>
<li>从浏览器中创建 <a href="javascript:;" target="_blank" rel="noopener">XMLHttpRequests</a></li>
<li>从 node.js 创建 <a href="javascript:;" target="_blank" rel="noopener">http</a> 请求</li>
<li>支持 <a href="javascript:;" target="_blank" rel="noopener">Promise</a> API</li>
<li>拦截请求和响应</li>
<li>转换请求数据和响应数据</li>
<li>取消请求</li>
<li>自动转换 JSON 数据</li>
<li>客户端支持防御 <a href="javascript:;" target="_blank" rel="noopener">XSRF</a></li>
</ul>
<h2 id="浏览器支持" class="article-heading"><a href="#浏览器支持" class="headerlink" title="浏览器支持"></a>浏览器支持<a class="article-anchor" href="#浏览器支持" aria-hidden="true"></a></h2><table>
<thead>
<tr>
<th><img src="https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome"></th>
<th><img src="https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox"></th>
<th><img src="https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari"></th>
<th><img src="https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png" alt="Opera"></th>
<th><img src="https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="Edge"></th>
<th><img src="https://raw.github.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png" alt="IE"></th>
</tr>
</thead>
<tbody>
<tr>
<td>Latest ✔</td>
<td>Latest ✔</td>
<td>Latest ✔</td>
<td>Latest ✔</td>
<td>Latest ✔</td>
<td>8+ ✔</td>
<td></td>
</tr>
</tbody>
</table>
<p><a href="javascript:;" target="_blank" rel="noopener"><img src="https://saucelabs.com/open_sauce/build_matrix/axios.svg" alt="Browser Matrix"></a></p>
<h2 id="安装" class="article-heading"><a href="#安装" class="headerlink" title="安装"></a>安装<a class="article-anchor" href="#安装" aria-hidden="true"></a></h2><p>使用 npm: </p>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ npm install axios</span><br></pre></td></tr></table></figure>
<p>使用 bower: </p>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ bower install axios</span><br></pre></td></tr></table></figure>
<p>使用 cdn: </p>
<figure class="highlight html"><table><tr><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">"https://unpkg.com/axios/dist/axios.min.js"</span>&gt;</span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h2 id="案例" class="article-heading"><a href="#案例" class="headerlink" title="案例"></a>案例<a class="article-anchor" href="#案例" aria-hidden="true"></a></h2><p>执行 <code>GET</code> 请求 </p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="comment">// 为给定 ID 的 user 创建请求</span></span><br><span class="line">axios.get(<span class="string">'/user?ID=12345'</span>)</span><br><span class="line">  .then(<span class="function"><span class="keyword">function</span> (<span class="params">response</span>) </span>&#123;</span><br><span class="line">    <span class="built_in">console</span>.log(response);</span><br><span class="line">  &#125;)</span><br><span class="line">  .catch(<span class="function"><span class="keyword">function</span> (<span class="params">error</span>) </span>&#123;</span><br><span class="line">    <span class="built_in">console</span>.log(error);</span><br><span class="line">  &#125;);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 上面的请求也可以这样做</span></span><br><span class="line">axios.get(<span class="string">'/user'</span>, &#123;</span><br><span class="line">    params: &#123;</span><br><span class="line">      ID: <span class="number">12345</span></span><br><span class="line">    &#125;</span><br><span class="line">  &#125;)</span><br><span class="line">  .then(<span class="function"><span class="keyword">function</span> (<span class="params">response</span>) </span>&#123;</span><br><span class="line">    <span class="built_in">console</span>.log(response);</span><br><span class="line">  &#125;)</span><br><span class="line">  .catch(<span class="function"><span class="keyword">function</span> (<span class="params">error</span>) </span>&#123;</span><br><span class="line">    <span class="built_in">console</span>.log(error);</span><br><span class="line">  &#125;);</span><br></pre></td></tr></table></figure>
<p>执行 <code>POST</code> 请求 </p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line">axios.post(<span class="string">'/user'</span>, &#123;</span><br><span class="line">    firstName: <span class="string">'Fred'</span>,</span><br><span class="line">    lastName: <span class="string">'Flintstone'</span></span><br><span class="line">  &#125;)</span><br><span class="line">  .then(<span class="function"><span class="keyword">function</span> (<span class="params">response</span>) </span>&#123;</span><br><span class="line">    <span class="built_in">console</span>.log(response);</span><br><span class="line">  &#125;)</span><br><span class="line">  .catch(<span class="function"><span class="keyword">function</span> (<span class="params">error</span>) </span>&#123;</span><br><span class="line">    <span class="built_in">console</span>.log(error);</span><br><span class="line">  &#125;);</span><br></pre></td></tr></table></figure>
<p>执行多个并发请求 </p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getUserAccount</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">  <span class="keyword">return</span> axios.get(<span class="string">'/user/12345'</span>);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getUserPermissions</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">  <span class="keyword">return</span> axios.get(<span class="string">'/user/12345/permissions'</span>);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">axios.all([getUserAccount(), getUserPermissions()])</span><br><span class="line">  .then(axios.spread(<span class="function"><span class="keyword">function</span> (<span class="params">acct, perms</span>) </span>&#123;</span><br><span class="line">    <span class="comment">// 两个请求现在都执行完成</span></span><br><span class="line">  &#125;));</span><br></pre></td></tr></table></figure>
<h2 id="axios-API" class="article-heading"><a href="#axios-API" class="headerlink" title="axios API"></a>axios API<a class="article-anchor" href="#axios-API" aria-hidden="true"></a></h2><p>可以通过向 <code>axios</code> 传递相关配置来创建请求</p>
<h5 id="axios-config" class="article-heading"><a href="#axios-config" class="headerlink" title="axios(config)"></a>axios(config)<a class="article-anchor" href="#axios-config" aria-hidden="true"></a></h5><figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="comment">// 发送 POST 请求</span></span><br><span class="line">axios(&#123;</span><br><span class="line">  method: <span class="string">'post'</span>,</span><br><span class="line">  url: <span class="string">'/user/12345'</span>,</span><br><span class="line">  data: &#123;</span><br><span class="line">    firstName: <span class="string">'Fred'</span>,</span><br><span class="line">    lastName: <span class="string">'Flintstone'</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="comment">// 获取远端图片</span></span><br><span class="line">axios(&#123;</span><br><span class="line">  method:<span class="string">'get'</span>,</span><br><span class="line">  url:<span class="string">'http://bit.ly/2mTM3nY'</span>,</span><br><span class="line">  responseType:<span class="string">'stream'</span></span><br><span class="line">&#125;)</span><br><span class="line">  .then(<span class="function"><span class="keyword">function</span>(<span class="params">response</span>) </span>&#123;</span><br><span class="line">  response.data.pipe(fs.createWriteStream(<span class="string">'ada_lovelace.jpg'</span>))</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>
<h5 id="axios-url-config" class="article-heading"><a href="#axios-url-config" class="headerlink" title="axios(url[, config])"></a>axios(url[, config])<a class="article-anchor" href="#axios-url-config" aria-hidden="true"></a></h5><figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="comment">// 发送 GET 请求（默认的方法）</span></span><br><span class="line">axios(<span class="string">'/user/12345'</span>);</span><br></pre></td></tr></table></figure>
<h3 id="请求方法的别名" class="article-heading"><a href="#请求方法的别名" class="headerlink" title="请求方法的别名"></a>请求方法的别名<a class="article-anchor" href="#请求方法的别名" aria-hidden="true"></a></h3><p>为方便起见，为所有支持的请求方法提供了别名 </p>
<h5 id="axios-request-config" class="article-heading"><a href="#axios-request-config" class="headerlink" title="axios.request(config)"></a>axios.request(config)<a class="article-anchor" href="#axios-request-config" aria-hidden="true"></a></h5><h5 id="axios-get-url-config" class="article-heading"><a href="#axios-get-url-config" class="headerlink" title="axios.get(url[, config])"></a>axios.get(url[, config])<a class="article-anchor" href="#axios-get-url-config" aria-hidden="true"></a></h5><h5 id="axios-delete-url-config" class="article-heading"><a href="#axios-delete-url-config" class="headerlink" title="axios.delete(url[, config])"></a>axios.delete(url[, config])<a class="article-anchor" href="#axios-delete-url-config" aria-hidden="true"></a></h5><h5 id="axios-head-url-config" class="article-heading"><a href="#axios-head-url-config" class="headerlink" title="axios.head(url[, config])"></a>axios.head(url[, config])<a class="article-anchor" href="#axios-head-url-config" aria-hidden="true"></a></h5><h5 id="axios-options-url-config" class="article-heading"><a href="#axios-options-url-config" class="headerlink" title="axios.options(url[, config])"></a>axios.options(url[, config])<a class="article-anchor" href="#axios-options-url-config" aria-hidden="true"></a></h5><h5 id="axios-post-url-data-config" class="article-heading"><a href="#axios-post-url-data-config" class="headerlink" title="axios.post(url[, data[, config]])"></a>axios.post(url[, data[, config]])<a class="article-anchor" href="#axios-post-url-data-config" aria-hidden="true"></a></h5><h5 id="axios-put-url-data-config" class="article-heading"><a href="#axios-put-url-data-config" class="headerlink" title="axios.put(url[, data[, config]])"></a>axios.put(url[, data[, config]])<a class="article-anchor" href="#axios-put-url-data-config" aria-hidden="true"></a></h5><h5 id="axios-patch-url-data-config" class="article-heading"><a href="#axios-patch-url-data-config" class="headerlink" title="axios.patch(url[, data[, config]])"></a>axios.patch(url[, data[, config]])<a class="article-anchor" href="#axios-patch-url-data-config" aria-hidden="true"></a></h5><h6 id="注意" class="article-heading"><a href="#注意" class="headerlink" title="注意"></a>注意<a class="article-anchor" href="#注意" aria-hidden="true"></a></h6><p>在使用别名方法时， <code>url</code>、<code>method</code>、<code>data</code> 这些属性都不必在配置中指定。 </p>
<h3 id="并发" class="article-heading"><a href="#并发" class="headerlink" title="并发"></a>并发<a class="article-anchor" href="#并发" aria-hidden="true"></a></h3><p>处理并发请求的助手函数 </p>
<h5 id="axios-all-iterable" class="article-heading"><a href="#axios-all-iterable" class="headerlink" title="axios.all(iterable)"></a>axios.all(iterable)<a class="article-anchor" href="#axios-all-iterable" aria-hidden="true"></a></h5><h5 id="axios-spread-callback" class="article-heading"><a href="#axios-spread-callback" class="headerlink" title="axios.spread(callback)"></a>axios.spread(callback)<a class="article-anchor" href="#axios-spread-callback" aria-hidden="true"></a></h5><h3 id="创建实例" class="article-heading"><a href="#创建实例" class="headerlink" title="创建实例"></a>创建实例<a class="article-anchor" href="#创建实例" aria-hidden="true"></a></h3><p>可以使用自定义配置新建一个 axios 实例 </p>
<h5 id="axios-create-config" class="article-heading"><a href="#axios-create-config" class="headerlink" title="axios.create([config])"></a>axios.create([config])<a class="article-anchor" href="#axios-create-config" aria-hidden="true"></a></h5><figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">const</span> instance = axios.create(&#123;</span><br><span class="line">  baseURL: <span class="string">'https://some-domain.com/api/'</span>,</span><br><span class="line">  timeout: <span class="number">1000</span>,</span><br><span class="line">  headers: &#123;<span class="string">'X-Custom-Header'</span>: <span class="string">'foobar'</span>&#125;</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>
<h3 id="实例方法" class="article-heading"><a href="#实例方法" class="headerlink" title="实例方法"></a>实例方法<a class="article-anchor" href="#实例方法" aria-hidden="true"></a></h3><p>以下是可用的实例方法。指定的配置将与实例的配置合并。</p>
<h5 id="axios-request-config-1" class="article-heading"><a href="#axios-request-config-1" class="headerlink" title="axios#request(config)"></a>axios#request(config)<a class="article-anchor" href="#axios-request-config-1" aria-hidden="true"></a></h5><h5 id="axios-get-url-config-1" class="article-heading"><a href="#axios-get-url-config-1" class="headerlink" title="axios#get(url[, config])"></a>axios#get(url[, config])<a class="article-anchor" href="#axios-get-url-config-1" aria-hidden="true"></a></h5><h5 id="axios-delete-url-config-1" class="article-heading"><a href="#axios-delete-url-config-1" class="headerlink" title="axios#delete(url[, config])"></a>axios#delete(url[, config])<a class="article-anchor" href="#axios-delete-url-config-1" aria-hidden="true"></a></h5><h5 id="axios-head-url-config-1" class="article-heading"><a href="#axios-head-url-config-1" class="headerlink" title="axios#head(url[, config])"></a>axios#head(url[, config])<a class="article-anchor" href="#axios-head-url-config-1" aria-hidden="true"></a></h5><h5 id="axios-options-url-config-1" class="article-heading"><a href="#axios-options-url-config-1" class="headerlink" title="axios#options(url[, config])"></a>axios#options(url[, config])<a class="article-anchor" href="#axios-options-url-config-1" aria-hidden="true"></a></h5><h5 id="axios-post-url-data-config-1" class="article-heading"><a href="#axios-post-url-data-config-1" class="headerlink" title="axios#post(url[, data[, config]])"></a>axios#post(url[, data[, config]])<a class="article-anchor" href="#axios-post-url-data-config-1" aria-hidden="true"></a></h5><h5 id="axios-put-url-data-config-1" class="article-heading"><a href="#axios-put-url-data-config-1" class="headerlink" title="axios#put(url[, data[, config]])"></a>axios#put(url[, data[, config]])<a class="article-anchor" href="#axios-put-url-data-config-1" aria-hidden="true"></a></h5><h5 id="axios-patch-url-data-config-1" class="article-heading"><a href="#axios-patch-url-data-config-1" class="headerlink" title="axios#patch(url[, data[, config]])"></a>axios#patch(url[, data[, config]])<a class="article-anchor" href="#axios-patch-url-data-config-1" aria-hidden="true"></a></h5><h2 id="请求配置" class="article-heading"><a href="#请求配置" class="headerlink" title="请求配置"></a>请求配置<a class="article-anchor" href="#请求配置" aria-hidden="true"></a></h2><p>这些是创建请求时可以用的配置选项。只有 <code>url</code> 是必需的。如果没有指定 <code>method</code>，请求将默认使用 <code>get</code> 方法。 </p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line">&#123;</span><br><span class="line">   <span class="comment">// `url` 是用于请求的服务器 URL</span></span><br><span class="line">  url: <span class="string">'/user'</span>,</span><br><span class="line"></span><br><span class="line">  <span class="comment">// `method` 是创建请求时使用的方法</span></span><br><span class="line">  method: <span class="string">'get'</span>, <span class="comment">// default</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">// `baseURL` 将自动加在 `url` 前面，除非 `url` 是一个绝对 URL。</span></span><br><span class="line">  <span class="comment">// 它可以通过设置一个 `baseURL` 便于为 axios 实例的方法传递相对 URL</span></span><br><span class="line">  baseURL: <span class="string">'https://some-domain.com/api/'</span>,</span><br><span class="line"></span><br><span class="line">  <span class="comment">// `transformRequest` 允许在向服务器发送前，修改请求数据</span></span><br><span class="line">  <span class="comment">// 只能用在 'PUT', 'POST' 和 'PATCH' 这几个请求方法</span></span><br><span class="line">  <span class="comment">// 后面数组中的函数必须返回一个字符串，或 ArrayBuffer，或 Stream</span></span><br><span class="line">  transformRequest: [<span class="function"><span class="keyword">function</span> (<span class="params">data, headers</span>) </span>&#123;</span><br><span class="line">    <span class="comment">// 对 data 进行任意转换处理</span></span><br><span class="line">    <span class="keyword">return</span> data;</span><br><span class="line">  &#125;],</span><br><span class="line"></span><br><span class="line">  <span class="comment">// `transformResponse` 在传递给 then/catch 前，允许修改响应数据</span></span><br><span class="line">  transformResponse: [<span class="function"><span class="keyword">function</span> (<span class="params">data</span>) </span>&#123;</span><br><span class="line">    <span class="comment">// 对 data 进行任意转换处理</span></span><br><span class="line">    <span class="keyword">return</span> data;</span><br><span class="line">  &#125;],</span><br><span class="line"></span><br><span class="line">  <span class="comment">// `headers` 是即将被发送的自定义请求头</span></span><br><span class="line">  headers: &#123;<span class="string">'X-Requested-With'</span>: <span class="string">'XMLHttpRequest'</span>&#125;,</span><br><span class="line"></span><br><span class="line">  <span class="comment">// `params` 是即将与请求一起发送的 URL 参数</span></span><br><span class="line">  <span class="comment">// 必须是一个无格式对象(plain object)或 URLSearchParams 对象</span></span><br><span class="line">  params: &#123;</span><br><span class="line">    ID: <span class="number">12345</span></span><br><span class="line">  &#125;,</span><br><span class="line"></span><br><span class="line">   <span class="comment">// `paramsSerializer` 是一个负责 `params` 序列化的函数</span></span><br><span class="line">  <span class="comment">// (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/)</span></span><br><span class="line">  paramsSerializer: <span class="function"><span class="keyword">function</span>(<span class="params">params</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> Qs.stringify(params, &#123;<span class="attr">arrayFormat</span>: <span class="string">'brackets'</span>&#125;)</span><br><span class="line">  &#125;,</span><br><span class="line"></span><br><span class="line">  <span class="comment">// `data` 是作为请求主体被发送的数据</span></span><br><span class="line">  <span class="comment">// 只适用于这些请求方法 'PUT', 'POST', 和 'PATCH'</span></span><br><span class="line">  <span class="comment">// 在没有设置 `transformRequest` 时，必须是以下类型之一：</span></span><br><span class="line">  <span class="comment">// - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams</span></span><br><span class="line">  <span class="comment">// - 浏览器专属：FormData, File, Blob</span></span><br><span class="line">  <span class="comment">// - Node 专属： Stream</span></span><br><span class="line">  data: &#123;</span><br><span class="line">    firstName: <span class="string">'Fred'</span></span><br><span class="line">  &#125;,</span><br><span class="line"></span><br><span class="line">  <span class="comment">// `timeout` 指定请求超时的毫秒数(0 表示无超时时间)</span></span><br><span class="line">  <span class="comment">// 如果请求话费了超过 `timeout` 的时间，请求将被中断</span></span><br><span class="line">  timeout: <span class="number">1000</span>,</span><br><span class="line"></span><br><span class="line">   <span class="comment">// `withCredentials` 表示跨域请求时是否需要使用凭证</span></span><br><span class="line">  withCredentials: <span class="literal">false</span>, <span class="comment">// default</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">// `adapter` 允许自定义处理请求，以使测试更轻松</span></span><br><span class="line">  <span class="comment">// 返回一个 promise 并应用一个有效的响应 (查阅 [response docs](#response-api)).</span></span><br><span class="line">  adapter: <span class="function"><span class="keyword">function</span> (<span class="params">config</span>) </span>&#123;</span><br><span class="line">    <span class="comment">/* ... */</span></span><br><span class="line">  &#125;,</span><br><span class="line"></span><br><span class="line"> <span class="comment">// `auth` 表示应该使用 HTTP 基础验证，并提供凭据</span></span><br><span class="line">  <span class="comment">// 这将设置一个 `Authorization` 头，覆写掉现有的任意使用 `headers` 设置的自定义 `Authorization`头</span></span><br><span class="line">  auth: &#123;</span><br><span class="line">    username: <span class="string">'janedoe'</span>,</span><br><span class="line">    password: <span class="string">'s00pers3cret'</span></span><br><span class="line">  &#125;,</span><br><span class="line"></span><br><span class="line">   <span class="comment">// `responseType` 表示服务器响应的数据类型，可以是 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream'</span></span><br><span class="line">  responseType: <span class="string">'json'</span>, <span class="comment">// default</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">// `responseEncoding` indicates encoding to use for decoding responses</span></span><br><span class="line">  <span class="comment">// Note: Ignored for `responseType` of 'stream' or client-side requests</span></span><br><span class="line">  responseEncoding: <span class="string">'utf8'</span>, <span class="comment">// default</span></span><br><span class="line"></span><br><span class="line">   <span class="comment">// `xsrfCookieName` 是用作 xsrf token 的值的cookie的名称</span></span><br><span class="line">  xsrfCookieName: <span class="string">'XSRF-TOKEN'</span>, <span class="comment">// default</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">// `xsrfHeaderName` is the name of the http header that carries the xsrf token value</span></span><br><span class="line">  xsrfHeaderName: <span class="string">'X-XSRF-TOKEN'</span>, <span class="comment">// default</span></span><br><span class="line"></span><br><span class="line">   <span class="comment">// `onUploadProgress` 允许为上传处理进度事件</span></span><br><span class="line">  onUploadProgress: <span class="function"><span class="keyword">function</span> (<span class="params">progressEvent</span>) </span>&#123;</span><br><span class="line">    <span class="comment">// Do whatever you want with the native progress event</span></span><br><span class="line">  &#125;,</span><br><span class="line"></span><br><span class="line">  <span class="comment">// `onDownloadProgress` 允许为下载处理进度事件</span></span><br><span class="line">  onDownloadProgress: <span class="function"><span class="keyword">function</span> (<span class="params">progressEvent</span>) </span>&#123;</span><br><span class="line">    <span class="comment">// 对原生进度事件的处理</span></span><br><span class="line">  &#125;,</span><br><span class="line"></span><br><span class="line">   <span class="comment">// `maxContentLength` 定义允许的响应内容的最大尺寸</span></span><br><span class="line">  maxContentLength: <span class="number">2000</span>,</span><br><span class="line"></span><br><span class="line">  <span class="comment">// `validateStatus` 定义对于给定的HTTP 响应状态码是 resolve 或 reject  promise 。如果 `validateStatus` 返回 `true` (或者设置为 `null` 或 `undefined`)，promise 将被 resolve; 否则，promise 将被 rejecte</span></span><br><span class="line">  validateStatus: <span class="function"><span class="keyword">function</span> (<span class="params">status</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> status &gt;= <span class="number">200</span> &amp;&amp; status &lt; <span class="number">300</span>; <span class="comment">// default</span></span><br><span class="line">  &#125;,</span><br><span class="line"></span><br><span class="line">  <span class="comment">// `maxRedirects` 定义在 node.js 中 follow 的最大重定向数目</span></span><br><span class="line">  <span class="comment">// 如果设置为0，将不会 follow 任何重定向</span></span><br><span class="line">  maxRedirects: <span class="number">5</span>, <span class="comment">// default</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">// `socketPath` defines a UNIX Socket to be used in node.js.</span></span><br><span class="line">  <span class="comment">// e.g. '/var/run/docker.sock' to send requests to the docker daemon.</span></span><br><span class="line">  <span class="comment">// Only either `socketPath` or `proxy` can be specified.</span></span><br><span class="line">  <span class="comment">// If both are specified, `socketPath` is used.</span></span><br><span class="line">  socketPath: <span class="literal">null</span>, <span class="comment">// default</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">// `httpAgent` 和 `httpsAgent` 分别在 node.js 中用于定义在执行 http 和 https 时使用的自定义代理。允许像这样配置选项：</span></span><br><span class="line">  <span class="comment">// `keepAlive` 默认没有启用</span></span><br><span class="line">  httpAgent: <span class="keyword">new</span> http.Agent(&#123; <span class="attr">keepAlive</span>: <span class="literal">true</span> &#125;),</span><br><span class="line">  httpsAgent: <span class="keyword">new</span> https.Agent(&#123; <span class="attr">keepAlive</span>: <span class="literal">true</span> &#125;),</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 'proxy' 定义代理服务器的主机名称和端口</span></span><br><span class="line">  <span class="comment">// `auth` 表示 HTTP 基础验证应当用于连接代理，并提供凭据</span></span><br><span class="line">  <span class="comment">// 这将会设置一个 `Proxy-Authorization` 头，覆写掉已有的通过使用 `header` 设置的自定义 `Proxy-Authorization` 头。</span></span><br><span class="line">  proxy: &#123;</span><br><span class="line">    host: <span class="string">'127.0.0.1'</span>,</span><br><span class="line">    port: <span class="number">9000</span>,</span><br><span class="line">    auth: &#123;</span><br><span class="line">      username: <span class="string">'mikeymike'</span>,</span><br><span class="line">      password: <span class="string">'rapunz3l'</span></span><br><span class="line">    &#125;</span><br><span class="line">  &#125;,</span><br><span class="line"></span><br><span class="line">  <span class="comment">// `cancelToken` 指定用于取消请求的 cancel token</span></span><br><span class="line">  <span class="comment">// （查看后面的 Cancellation 这节了解更多）</span></span><br><span class="line">  cancelToken: <span class="keyword">new</span> CancelToken(<span class="function"><span class="keyword">function</span> (<span class="params">cancel</span>) </span>&#123;</span><br><span class="line">  &#125;)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="响应结构" class="article-heading"><a href="#响应结构" class="headerlink" title="响应结构"></a>响应结构<a class="article-anchor" href="#响应结构" aria-hidden="true"></a></h2><p>某个请求的响应包含以下信息 </p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  <span class="comment">// `data` 由服务器提供的响应</span></span><br><span class="line">  data: &#123;&#125;,</span><br><span class="line"></span><br><span class="line">  <span class="comment">// `status` 来自服务器响应的 HTTP 状态码</span></span><br><span class="line">  status: <span class="number">200</span>,</span><br><span class="line"></span><br><span class="line">  <span class="comment">// `statusText` 来自服务器响应的 HTTP 状态信息</span></span><br><span class="line">  statusText: <span class="string">'OK'</span>,</span><br><span class="line"></span><br><span class="line">  <span class="comment">// `headers` 服务器响应的头</span></span><br><span class="line">  headers: &#123;&#125;,</span><br><span class="line"></span><br><span class="line">   <span class="comment">// `config` 是为请求提供的配置信息</span></span><br><span class="line">  config: &#123;&#125;,</span><br><span class="line"> <span class="comment">// 'request'</span></span><br><span class="line">  <span class="comment">// `request` is the request that generated this response</span></span><br><span class="line">  <span class="comment">// It is the last ClientRequest instance in node.js (in redirects)</span></span><br><span class="line">  <span class="comment">// and an XMLHttpRequest instance the browser</span></span><br><span class="line">  request: &#123;&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>使用 <code>then</code> 时，你将接收下面这样的响应 :</p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line">axios.get(<span class="string">'/user/12345'</span>)</span><br><span class="line">  .then(<span class="function"><span class="keyword">function</span>(<span class="params">response</span>) </span>&#123;</span><br><span class="line">    <span class="built_in">console</span>.log(response.data);</span><br><span class="line">    <span class="built_in">console</span>.log(response.status);</span><br><span class="line">    <span class="built_in">console</span>.log(response.statusText);</span><br><span class="line">    <span class="built_in">console</span>.log(response.headers);</span><br><span class="line">    <span class="built_in">console</span>.log(response.config);</span><br><span class="line">  &#125;);</span><br></pre></td></tr></table></figure>
<p>在使用 <code>catch</code> 时，或传递 <a href="javascript:;" target="_blank" rel="noopener">rejection callback</a> 作为 <code>then</code> 的第二个参数时，响应可以通过 <code>error</code> 对象可被使用，正如在<a href="javascript:;" target="_blank" rel="noopener">错误处理</a>这一节所讲。 </p>
<h2 id="配置默认值" class="article-heading"><a href="#配置默认值" class="headerlink" title="配置默认值"></a>配置默认值<a class="article-anchor" href="#配置默认值" aria-hidden="true"></a></h2><p>你可以指定将被用在各个请求的配置默认值 </p>
<h3 id="全局的-axios-默认值" class="article-heading"><a href="#全局的-axios-默认值" class="headerlink" title="全局的 axios 默认值"></a>全局的 axios 默认值<a class="article-anchor" href="#全局的-axios-默认值" aria-hidden="true"></a></h3><figure class="highlight js"><table><tr><td class="code"><pre><span class="line">axios.defaults.baseURL = <span class="string">'https://api.example.com'</span>;</span><br><span class="line">axios.defaults.headers.common[<span class="string">'Authorization'</span>] = AUTH_TOKEN;</span><br><span class="line">axios.defaults.headers.post[<span class="string">'Content-Type'</span>] = <span class="string">'application/x-www-form-urlencoded'</span>;</span><br></pre></td></tr></table></figure>
<h3 id="自定义实例默认值" class="article-heading"><a href="#自定义实例默认值" class="headerlink" title="自定义实例默认值"></a>自定义实例默认值<a class="article-anchor" href="#自定义实例默认值" aria-hidden="true"></a></h3><figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="comment">// Set config defaults when creating the instance</span></span><br><span class="line"><span class="keyword">const</span> instance = axios.create(&#123;</span><br><span class="line">  baseURL: <span class="string">'https://api.example.com'</span></span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line"><span class="comment">// Alter defaults after instance has been created</span></span><br><span class="line">instance.defaults.headers.common[<span class="string">'Authorization'</span>] = AUTH_TOKEN;</span><br></pre></td></tr></table></figure>
<h3 id="配置的优先顺序" class="article-heading"><a href="#配置的优先顺序" class="headerlink" title="配置的优先顺序"></a>配置的优先顺序<a class="article-anchor" href="#配置的优先顺序" aria-hidden="true"></a></h3><p>配置会以一个优先顺序进行合并。这个顺序是：在 <code>lib/defaults.js</code> 找到的库的默认值，然后是实例的 <code>defaults</code> 属性，最后是请求的 <code>config</code> 参数。后者将优先于前者。这里是一个例子： </p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="comment">// 使用由库提供的配置的默认值来创建实例</span></span><br><span class="line"><span class="comment">// 此时超时配置的默认值是 `0`</span></span><br><span class="line"><span class="keyword">var</span> instance = axios.create();</span><br><span class="line"></span><br><span class="line"><span class="comment">// 覆写库的超时默认值</span></span><br><span class="line"><span class="comment">// 现在，在超时前，所有请求都会等待 2.5 秒</span></span><br><span class="line">instance.defaults.timeout = <span class="number">2500</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 为已知需要花费很长时间的请求覆写超时设置</span></span><br><span class="line">instance.get(<span class="string">'/longRequest'</span>, &#123;</span><br><span class="line">  timeout: <span class="number">5000</span></span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>
<h2 id="拦截器" class="article-heading"><a href="#拦截器" class="headerlink" title="拦截器"></a>拦截器<a class="article-anchor" href="#拦截器" aria-hidden="true"></a></h2><p>在请求或响应被 <code>then</code> 或 <code>catch</code> 处理前拦截它们。 </p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="comment">// 添加请求拦截器</span></span><br><span class="line">axios.interceptors.request.use(<span class="function"><span class="keyword">function</span> (<span class="params">config</span>) </span>&#123;</span><br><span class="line">    <span class="comment">// 在发送请求之前做些什么</span></span><br><span class="line">    <span class="keyword">return</span> config;</span><br><span class="line">  &#125;, <span class="function"><span class="keyword">function</span> (<span class="params">error</span>) </span>&#123;</span><br><span class="line">    <span class="comment">// 对请求错误做些什么</span></span><br><span class="line">    <span class="keyword">return</span> <span class="built_in">Promise</span>.reject(error);</span><br><span class="line">  &#125;);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 添加响应拦截器</span></span><br><span class="line">axios.interceptors.response.use(<span class="function"><span class="keyword">function</span> (<span class="params">response</span>) </span>&#123;</span><br><span class="line">    <span class="comment">// 对响应数据做点什么</span></span><br><span class="line">    <span class="keyword">return</span> response;</span><br><span class="line">  &#125;, <span class="function"><span class="keyword">function</span> (<span class="params">error</span>) </span>&#123;</span><br><span class="line">    <span class="comment">// 对响应错误做点什么</span></span><br><span class="line">    <span class="keyword">return</span> <span class="built_in">Promise</span>.reject(error);</span><br><span class="line">  &#125;);</span><br></pre></td></tr></table></figure>
<p>如果你想在稍后移除拦截器，可以这样： </p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">const</span> myInterceptor = axios.interceptors.request.use(<span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;<span class="comment">/*...*/</span>&#125;);</span><br><span class="line">axios.interceptors.request.eject(myInterceptor);</span><br></pre></td></tr></table></figure>
<p>可以为自定义 axios 实例添加拦截器 </p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">const</span> instance = axios.create();</span><br><span class="line">instance.interceptors.request.use(<span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;<span class="comment">/*...*/</span>&#125;);</span><br></pre></td></tr></table></figure>
<h2 id="错误处理" class="article-heading"><a href="#错误处理" class="headerlink" title="错误处理"></a>错误处理<a class="article-anchor" href="#错误处理" aria-hidden="true"></a></h2><figure class="highlight js"><table><tr><td class="code"><pre><span class="line">axios.get(<span class="string">'/user/12345'</span>)</span><br><span class="line">  .catch(<span class="function"><span class="keyword">function</span> (<span class="params">error</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">if</span> (error.response) &#123;</span><br><span class="line">      <span class="comment">// The request was made and the server responded with a status code</span></span><br><span class="line">      <span class="comment">// that falls out of the range of 2xx</span></span><br><span class="line">      <span class="built_in">console</span>.log(error.response.data);</span><br><span class="line">      <span class="built_in">console</span>.log(error.response.status);</span><br><span class="line">      <span class="built_in">console</span>.log(error.response.headers);</span><br><span class="line">    &#125; <span class="keyword">else</span> <span class="keyword">if</span> (error.request) &#123;</span><br><span class="line">      <span class="comment">// The request was made but no response was received</span></span><br><span class="line">      <span class="comment">// `error.request` is an instance of XMLHttpRequest in the browser and an instance of</span></span><br><span class="line">      <span class="comment">// http.ClientRequest in node.js</span></span><br><span class="line">      <span class="built_in">console</span>.log(error.request);</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">      <span class="comment">// Something happened in setting up the request that triggered an Error</span></span><br><span class="line">      <span class="built_in">console</span>.log(<span class="string">'Error'</span>, error.message);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="built_in">console</span>.log(error.config);</span><br><span class="line">  &#125;);</span><br></pre></td></tr></table></figure>
<p>Y可以使用 <code>validateStatus</code> 配置选项定义一个自定义 HTTP 状态码的错误范围。 </p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line">axios.get(<span class="string">'/user/12345'</span>, &#123;</span><br><span class="line">  validateStatus: <span class="function"><span class="keyword">function</span> (<span class="params">status</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> status &lt; <span class="number">500</span>; <span class="comment">// Reject only if the status code is greater than or equal to 500</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>
<h2 id="取消" class="article-heading"><a href="#取消" class="headerlink" title="取消"></a>取消<a class="article-anchor" href="#取消" aria-hidden="true"></a></h2><p>使用 <em>cancel token</em> 取消请求</p>
<blockquote>
<p>Axios 的 cancel token API 基于<a href="javascript:;" target="_blank" rel="noopener">cancelable promises proposal</a>，它还处于第一阶段。 </p>
</blockquote>
<p>可以使用 <code>CancelToken.source</code> 工厂方法创建 cancel token，像这样： </p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">const</span> CancelToken = axios.CancelToken;</span><br><span class="line"><span class="keyword">const</span> source = CancelToken.source();</span><br><span class="line"></span><br><span class="line">axios.get(<span class="string">'/user/12345'</span>, &#123;</span><br><span class="line">  cancelToken: source.token</span><br><span class="line">&#125;).catch(<span class="function"><span class="keyword">function</span>(<span class="params">thrown</span>) </span>&#123;</span><br><span class="line">  <span class="keyword">if</span> (axios.isCancel(thrown)) &#123;</span><br><span class="line">    <span class="built_in">console</span>.log(<span class="string">'Request canceled'</span>, thrown.message);</span><br><span class="line">  &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">     <span class="comment">// 处理错误</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line">axios.post(<span class="string">'/user/12345'</span>, &#123;</span><br><span class="line">  name: <span class="string">'new name'</span></span><br><span class="line">&#125;, &#123;</span><br><span class="line">  cancelToken: source.token</span><br><span class="line">&#125;)</span><br><span class="line"></span><br><span class="line"><span class="comment">// 取消请求（message 参数是可选的）</span></span><br><span class="line">source.cancel(<span class="string">'Operation canceled by the user.'</span>);</span><br></pre></td></tr></table></figure>
<p>还可以通过传递一个 executor 函数到 <code>CancelToken</code> 的构造函数来创建 cancel token： </p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">const</span> CancelToken = axios.CancelToken;</span><br><span class="line"><span class="keyword">let</span> cancel;</span><br><span class="line"></span><br><span class="line">axios.get(<span class="string">'/user/12345'</span>, &#123;</span><br><span class="line">  cancelToken: <span class="keyword">new</span> CancelToken(<span class="function"><span class="keyword">function</span> <span class="title">executor</span>(<span class="params">c</span>) </span>&#123;</span><br><span class="line">    <span class="comment">// executor 函数接收一个 cancel 函数作为参数</span></span><br><span class="line">    cancel = c;</span><br><span class="line">  &#125;)</span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line"><span class="comment">// cancel the request</span></span><br><span class="line">cancel();</span><br></pre></td></tr></table></figure>
<blockquote>
<p>注意: 可以使用同一个 cancel token 取消多个请求 </p>
</blockquote>
<h2 id="使用-application-x-www-form-urlencoded-format" class="article-heading"><a href="#使用-application-x-www-form-urlencoded-format" class="headerlink" title="使用 application/x-www-form-urlencoded format"></a>使用 application/x-www-form-urlencoded format<a class="article-anchor" href="#使用-application-x-www-form-urlencoded-format" aria-hidden="true"></a></h2><p>默认情况下，axios将JavaScript对象序列化为JSON。 要以application / x-www-form-urlencoded格式发送数据，您可以使用以下选项之一。</p>
<h3 id="浏览器" class="article-heading"><a href="#浏览器" class="headerlink" title="浏览器"></a>浏览器<a class="article-anchor" href="#浏览器" aria-hidden="true"></a></h3><p>在浏览器中，您可以使用URLSearchParams API，如下所示：</p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">const</span> params = <span class="keyword">new</span> URLSearchParams();</span><br><span class="line">params.append(<span class="string">'param1'</span>, <span class="string">'value1'</span>);</span><br><span class="line">params.append(<span class="string">'param2'</span>, <span class="string">'value2'</span>);</span><br><span class="line">axios.post(<span class="string">'/foo'</span>, params);</span><br></pre></td></tr></table></figure>
<blockquote>
<p>请注意，所有浏览器都不支持URLSearchParams（请参阅caniuse.com），但可以使用polyfill（确保填充全局环境）。</p>
</blockquote>
<p>或者，您可以使用qs库编码数据：</p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">const</span> qs = <span class="built_in">require</span>(<span class="string">'qs'</span>);</span><br><span class="line">axios.post(<span class="string">'/foo'</span>, qs.stringify(&#123; <span class="string">'bar'</span>: <span class="number">123</span> &#125;));</span><br></pre></td></tr></table></figure>
<p>或者以另一种方式（ES6），</p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">import</span> qs <span class="keyword">from</span> <span class="string">'qs'</span>;</span><br><span class="line"><span class="keyword">const</span> data = &#123; <span class="string">'bar'</span>: <span class="number">123</span> &#125;;</span><br><span class="line"><span class="keyword">const</span> options = &#123;</span><br><span class="line">  method: <span class="string">'POST'</span>,</span><br><span class="line">  headers: &#123; <span class="string">'content-type'</span>: <span class="string">'application/x-www-form-urlencoded'</span> &#125;,</span><br><span class="line">  data: qs.stringify(data),</span><br><span class="line">  url,</span><br><span class="line">&#125;;</span><br><span class="line">axios(options);</span><br></pre></td></tr></table></figure>
<h3 id="Node-js" class="article-heading"><a href="#Node-js" class="headerlink" title="Node.js"></a>Node.js<a class="article-anchor" href="#Node-js" aria-hidden="true"></a></h3><p>在node.js中，您可以使用querystring模块，如下所示：</p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">const</span> querystring = <span class="built_in">require</span>(<span class="string">'querystring'</span>);</span><br><span class="line">axios.post(<span class="string">'http://something.com/'</span>, querystring.stringify(&#123; <span class="attr">foo</span>: <span class="string">'bar'</span> &#125;));</span><br></pre></td></tr></table></figure>
<p>您也可以使用qs库。</p>
<h2 id="Semver" class="article-heading"><a href="#Semver" class="headerlink" title="Semver"></a>Semver<a class="article-anchor" href="#Semver" aria-hidden="true"></a></h2><p>在axios达到1.0版本之前，破坏性更改将以新的次要版本发布。 例如0.5.1和0.5.4将具有相同的API，但0.6.0将具有重大变化。</p>
<h2 id="Promises" class="article-heading"><a href="#Promises" class="headerlink" title="Promises"></a>Promises<a class="article-anchor" href="#Promises" aria-hidden="true"></a></h2><p>axios 依赖原生的 ES6 Promise 实现而<a href="javascript:;" target="_blank" rel="noopener">被支持</a>. 如果你的环境不支持 ES6 Promise，你可以使用 <a href="javascript:;" target="_blank" rel="noopener">polyfill</a>. </p>
<h2 id="TypeScript" class="article-heading"><a href="#TypeScript" class="headerlink" title="TypeScript"></a>TypeScript<a class="article-anchor" href="#TypeScript" aria-hidden="true"></a></h2><p>axios包括TypeScript定义。<br><figure class="highlight typescript"><table><tr><td class="code"><pre><span class="line"><span class="keyword">import</span> axios <span class="keyword">from</span> <span class="string">'axios'</span>;</span><br><span class="line">axios.get(<span class="string">'/user?ID=12345'</span>);</span><br></pre></td></tr></table></figure></p>
<h2 id="资源" class="article-heading"><a href="#资源" class="headerlink" title="资源"></a>资源<a class="article-anchor" href="#资源" aria-hidden="true"></a></h2><ul>
<li><a href="javascript:;" target="_blank" rel="noopener">Changelog</a></li>
<li><a href="javascript:;" target="_blank" rel="noopener">Upgrade Guide</a></li>
<li><a href="javascript:;" target="_blank" rel="noopener">Ecosystem</a></li>
<li><a href="javascript:;" target="_blank" rel="noopener">Contributing Guide</a></li>
<li><a href="javascript:;" target="_blank" rel="noopener">Code of Conduct</a></li>
</ul>
<h2 id="Credits" class="article-heading"><a href="#Credits" class="headerlink" title="Credits"></a>Credits<a class="article-anchor" href="#Credits" aria-hidden="true"></a></h2><p>axios深受Angular提供的、\$http服务的启发。 最终，axios是为了在Angular之外使用而提供独立的类似\$http服的务。</p>
<h2 id="协议" class="article-heading"><a href="#协议" class="headerlink" title="协议"></a>协议<a class="article-anchor" href="#协议" aria-hidden="true"></a></h2><p>MIT</p>
<div class="recommand">以下课程十分推荐想往前端架构师方向精进的同学，月入5万的梦想总要有的！投资自己就是最好的投资！</div><div class="lessonlist"><div class="lession"><a href="javascript:;" target="_blank" rel="noopener"><img src="static/picture/les01.jpeg" class="lesspic"></a></div><div class="lession"><a href="javascript:;" target="_blank" rel="noopener"><img src="static/picture/les02.jpeg" class="lesspic"></a></div><div class="lession"><a href="javascript:;" target="_blank" rel="noopener"><img src="static/picture/les03.jpeg" class="lesspic"></a></div><div class="lession"><a href="javascript:;" target="_blank" rel="noopener"><img src="static/picture/les04.jpeg" class="lesspic"></a></div></div>



              </div>
              <footer class="article-footer">
                <time class="article-footer-updated" datetime="2021-10-28T14:07:53.000Z" itemprop="dateModified">上次更新：2021-10-28</time>
                <a href="vue-axios.html" class="article-footer-next" title="vue-axios"><span>下一页</span><i class="fa fa-chevron-right"></i></a>
              </footer>
              
            </div>
          </div>
          <aside id="article-toc" role="navigation">
            <div id="article-toc-inner">
              <strong class="sidebar-title">目录</strong>
              <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#什么是-axios？"><span class="toc-text">什么是 axios？</span></a></li></ol><li class="toc-item toc-level-1"><a class="toc-link" href="#axios"><span class="toc-text">axios</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#特性"><span class="toc-text">特性</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#浏览器支持"><span class="toc-text">浏览器支持</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#安装"><span class="toc-text">安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#案例"><span class="toc-text">案例</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#axios-API"><span class="toc-text">axios API</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-config"><span class="toc-text">axios(config)</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-url-config"><span class="toc-text">axios(url[, config])</span></a></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#请求方法的别名"><span class="toc-text">请求方法的别名</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-request-config"><span class="toc-text">axios.request(config)</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-get-url-config"><span class="toc-text">axios.get(url[, config])</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-delete-url-config"><span class="toc-text">axios.delete(url[, config])</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-head-url-config"><span class="toc-text">axios.head(url[, config])</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-options-url-config"><span class="toc-text">axios.options(url[, config])</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-post-url-data-config"><span class="toc-text">axios.post(url[, data[, config]])</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-put-url-data-config"><span class="toc-text">axios.put(url[, data[, config]])</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-patch-url-data-config"><span class="toc-text">axios.patch(url[, data[, config]])</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#注意"><span class="toc-text">注意</span></a></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#并发"><span class="toc-text">并发</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-all-iterable"><span class="toc-text">axios.all(iterable)</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-spread-callback"><span class="toc-text">axios.spread(callback)</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#创建实例"><span class="toc-text">创建实例</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-create-config"><span class="toc-text">axios.create([config])</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#实例方法"><span class="toc-text">实例方法</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-request-config-1"><span class="toc-text">axios#request(config)</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-get-url-config-1"><span class="toc-text">axios#get(url[, config])</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-delete-url-config-1"><span class="toc-text">axios#delete(url[, config])</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-head-url-config-1"><span class="toc-text">axios#head(url[, config])</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-options-url-config-1"><span class="toc-text">axios#options(url[, config])</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-post-url-data-config-1"><span class="toc-text">axios#post(url[, data[, config]])</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-put-url-data-config-1"><span class="toc-text">axios#put(url[, data[, config]])</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#axios-patch-url-data-config-1"><span class="toc-text">axios#patch(url[, data[, config]])</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#请求配置"><span class="toc-text">请求配置</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#响应结构"><span class="toc-text">响应结构</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#配置默认值"><span class="toc-text">配置默认值</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#全局的-axios-默认值"><span class="toc-text">全局的 axios 默认值</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#自定义实例默认值"><span class="toc-text">自定义实例默认值</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#配置的优先顺序"><span class="toc-text">配置的优先顺序</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#拦截器"><span class="toc-text">拦截器</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#错误处理"><span class="toc-text">错误处理</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#取消"><span class="toc-text">取消</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#使用-application-x-www-form-urlencoded-format"><span class="toc-text">使用 application&#x2F;x-www-form-urlencoded format</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#浏览器"><span class="toc-text">浏览器</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Node-js"><span class="toc-text">Node.js</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Semver"><span class="toc-text">Semver</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Promises"><span class="toc-text">Promises</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#TypeScript"><span class="toc-text">TypeScript</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#资源"><span class="toc-text">资源</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Credits"><span class="toc-text">Credits</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#协议"><span class="toc-text">协议</span></a></li>
              <a href="#" id="article-toc-top">回到顶部</a>
            </div>
          </aside>
        </div>
      </article>
      <aside id="sidebar" role="navigation">
  <div class="inner">
    <strong class="sidebar-title">开始使用</strong><a href="" class="sidebar-link current">概述</a><strong class="sidebar-title">框架整合</strong><a href="vue-axios.html" class="sidebar-link">vue-axios</a><a href="nuxtjs-axios.html" class="sidebar-link">nuxtjs-axios</a><a href="react-axios.html" class="sidebar-link">react-axios</a><strong class="sidebar-title">Plugins</strong><a href="axios-retry.html" class="sidebar-link">axios-retry</a><a href="vue-axios-plugin.html" class="sidebar-link">vue-axios-plugin</a>
  </div>
</aside>
    </div>
  </div>
</div>

    <footer id="footer" class="wrapper">
  <div class="inner">
    <div id="footer-copyright">
      &copy; 2021 axios中文网<br>
      Documentation licensed under <a href="javascript:;" target="_blank">CC BY 4.0</a>.
    </div>
    <div id="footer-links">
      <a href="javascript:;" class="footer-link" target="_blank"><i class="fa fa-twitter"></i></a>
      <a href="javascript:;" class="footer-link" target="_blank"><i class="fa fa-github-alt"></i></a>
    </div>
  </div>
</footer>

  </div>
  <div id="mobile-nav-dimmer"></div>
  <nav id="mobile-nav">
  <div id="mobile-nav-inner">
    <ul id="mobile-nav-list">
      <a href="" class="mobile-nav-link">文档</a><a href="index2.html" class="mobile-nav-link">博客</a>
      <li class="mobile-nav-item">
        <a href="javascript:;" class="mobile-nav-link" rel="external" target="_blank">GitHub</a>
      </li>
    </ul>
    
      <strong class="mobile-nav-title">开始使用</strong><a href="" class="mobile-nav-link current">概述</a><strong class="mobile-nav-title">框架整合</strong><a href="vue-axios.html" class="mobile-nav-link">vue-axios</a><a href="nuxtjs-axios.html" class="mobile-nav-link">nuxtjs-axios</a><a href="react-axios.html" class="mobile-nav-link">react-axios</a><strong class="mobile-nav-title">Plugins</strong><a href="axios-retry.html" class="mobile-nav-link">axios-retry</a><a href="vue-axios-plugin.html" class="mobile-nav-link">vue-axios-plugin</a>
    
  </div>
  <div id="mobile-lang-select-wrap">
    <span id="mobile-lang-select-label"><i class="fa fa-globe"></i><span>简体中文</span></span>
    <select id="mobile-lang-select" data-canonical="docs/index.html">
      
        <option value="en">undefined</option>
      
        <option value="zh-cn" selected="">简体中文</option>
      
    </select>
  </div>
</nav>
  <!-- Scripts -->
<!-- build:js build/js/main.js -->

<script src="static/js/lang_select.js"></script>


<script src="static/js/toc.js"></script>


<script src="static/js/mobile_nav.js"></script>

<!-- endbuild -->

<!-- Algolia -->




<div class="popup-container">
  
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pure/1.0.1/pure-min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/8.11.8/sweetalert2.min.css">
<style>
    #magic-popup {
        color: #000;
        
    }
    .vultr-coupon {
        margin-top: 20px
    }
    .popup-container {
        visibility: hidden;
        position: relative
    }

    .coupon {
        font-size: 16px;
    }
    .desc {
        margin-top: 10px;
        color: #03a9f4;
        font-size: 16px;
    }
    .reason {
        position: absolute;
        bottom: 0;
        right: 10px;
        width: 100%;
        font-size: 12px;
        color: red
    }

    .red-packet {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    #magic-popup{
        height: 200px
    }

    .campaign-tip {
        font-size: 14px;
        letter-spacing: 0
    }
</style>
<div class="popup-container">
<div id="magic-popup" class="magic-popup">
    <div class="pure-g"> 
            <a href="javascript:;" class="red-packet">
            <img width="150" src="https://res.cloudinary.com/dq9x329zv/image/upload/v1600435375/redpacket_n6cqu1.jpg">
            
            <span class="campaign-tip">拼多多新人专享红包！最高188元，限时领取！还有新人0元购，更多福利等你来拿~>></span>
            </a>
    </div>

    <!-- >
    <div class="pure-g">
            <div class="pure-u-12-24">
              <a class="pure-button pure-button-primary coupon" href="http://bit.ly/2PpdaHG" target="_blank" rel="noopener" class="btn btn-default btn-md" role="button">virmach特价vps</a>
            </div>

            <div class="pure-u-12-24">
              <a class="pure-button pure-button-primary coupon" href="http://bit.ly/2NDPn4N" target="_blank" rel="noopener" class="btn btn-default btn-md" role="button">vultr新户送$100</a>
            </div>
                
    </div>
    <div class="desc">
    vps可用来搭建博客，学习Linux，搭建个人网盘，私人git，
    可以搭建ssr一键使用google,搜索资料更方便。以上支持支付宝付款。
    </div>

    <div class="reason">
        广告费用用于支持本站服务器费用，希望大家理解
    </div> 

    <-->

    
    
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/8.11.8/sweetalert2.all.js"></script>
<script src="static/js/js.cookie.min.js"></script>

<script type="text/javascript">
var result = Cookies.get('popuped');
if(result){

} else {
Cookies.set('popuped', '1', { expires: 7 })
// Swal.fire({
//   title: '<strong></strong>',
//   icon: 'info',
//   html: $('#magic-popup'),
//   focusConfirm: false,
//   confirmButtonText: '知道了'
// })
}


</script>





</body>
</html>